#!/usr/bin/env python
from squirrel_core.commons.database import ProviderType

from squirrel_core.procedure.dataprocedure import DefaultProcedure

__all__ = ["SsdbProcedure"]


class SsdbProcedure(DefaultProcedure):
    """
    ssdb procedure to support ssdb data operation
    """

    @property
    def procedure_name(self):
        return ProviderType.SSDB

    def process_table_name(self, item_dict, *args, **kwargs):
        if "table_name" not in item_dict:
            item_dict["table_name"] = "{}_{}".format(item_dict.get("name_first"), item_dict.get("name_second"))

    def process_item(self, item_dict, *args, **kwargs):
        self.fill_suffix_q_name(item_dict, *args, **kwargs)
        self.process_table_name(item_dict, *args, **kwargs)
